﻿using System;
using Microsoft.WindowsAzure.StorageClient;

namespace LCA.Community.DAL.Model
{
    /// <summary>
    /// This class contains a single pair of message and receiver.
    /// 
    /// RowKey = Destionation ID
    /// PartitionKey = ID of the message.
    /// </summary>
    public class MessageRecipent : BasicDataModel
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageRecipent"/> class.
        /// </summary>
        public MessageRecipent()
        {

        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageRecipent"/> class.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="addreesse">The recipent.</param>
        public MessageRecipent(string message, string recipent)
        {
            RowKey = Guid.NewGuid().ToString();
            PartitionKey = message;
            Recipent = recipent;
        }

        /// <summary>
        /// Equalses the specified obj.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <returns><c>true</c> if both objects are equals; otherwise, <c>false</c>.</returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return false;
            }

            MessageRecipent u = obj as MessageRecipent;
            if ((System.Object)u == null)
            {
                return false;
            }

            return RowKey.Equals(u.RowKey);
        }

        /// <summary>
        /// Gets the hash code.
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        /// <summary>
        /// Gets or sets the sender.
        /// </summary>
        /// <value>The sender.</value>
        public string Message
        {
            get
            {
                return PartitionKey;
            }
            set
            {
                PartitionKey = value;
            }
        }
        /// <summary>
        /// Gets or sets the receiver of the message.
        /// </summary>
        /// <value>The message's receiver.</value>
        public string Recipent { get; set; }
    }
}
